//
//  SocketEngine.h
//  HelloWorld
//
//  Created by wuyifan on 11-6-22.
//  Copyright 2011 home. All rights reserved.
//

#import "AsyncSocket.h"
#import "EventListener.h"


@interface SocketEngine : NSObject <AsyncSocketDelegate>
{
	AsyncSocket* m_socket;
    EventListener* m_listener;
	
	BOOL m_isConnected;
	
	char m_recvBuff[BUFFERSIZE];												
	char m_sendBuff[BUFFERSIZE];
	
	size_t m_recvLen;
	size_t m_procLen;
	size_t m_readLen;
	
	MessageHeader* m_msgHeader;
	size_t m_sendLen;
}

- (BOOL)connect: (NSString *) hostIP port:(int) hostPort;
- (void)close;
- (void)setEventListener: (EventListener*) listener;

- (int)ReadInt;
- (void*) ReadData: (size_t) size;
//- (void*) ReadMutableData:(size_t) size;
- (void) NewMessage: (int) cmdId;
- (void) WriteInt: (int) data;
- (void*) WriteNonData: (size_t) size;
- (void) WriteData: (NSData *)data;
- (void) Send;

@end
